@extends('public.dashboard_base')
@section('title', '个人认证')

@section('content')
    @php
        $user =auth('admin')->user();
    @endphp
    <div class="control_panel_content">
        <div class="navBreadcrumb">
            <ul>
                <li>账户管理</li>
                <li>我的认证</li>
                <li>个人认证</li>
            </ul>
        </div>
        <div class="panel">
            <div class="sub_nav_container">
                <ul class="clearfix">
                    <li class="active"><a href="/account/auth/personal">个人认证</a></li>
                    <li><a href="/account/auth/personal/add">添加个人认证</a></li>
                </ul>
            </div>
            <div class="search_cond_wrap">
                <div>
                    <form id="queryForm">
                        <span>类型：</span>
                        <select name="queryType" id="search_away">
                            <option @if($queryType =='name') selected @endif  value="name">姓名</option>
                            <option @if($queryType =='number') selected @endif  value="number">证件号码</option>
                        </select>
                        <input type="text" name="queryValue" id="search_text" placeholder="请输入搜索">&ensp;
                        <input type="submit" class="btn btn_primary" id="queryBtn" value="搜索">
                        <input type="reset" class="btn btn_default" id="resetBtn" value="重置">
                    </form>
                </div>
            </div>
            <section class="mainResult">
                搜索结果<span class="text_orange">（<span id="total-rows">0</span>）</span>
            </section>
            <table class="table_style">
                <thead>
                <tr>
                    <th width="15%">姓名</th>
                    <th width="15%">证件类型</th>
                    <th width="15%">证件号码</th>
                    <th width="15%">提交时间</th>
                    <th width="10%">状态</th>
                    <th width="10%">操作</th>
                </tr>
                </thead>
                <tbody class="auth_id_card_list">
                @forelse($data as $item)
                    <tr>
                        <td>{{$item->name}}</td>
                        <td>{{$item->type}}</td>
                        <td>{{$item->number}}</td>
                        <td>{{$item->updated_at}}</td>
                        <td>
                            @if($item->status ==0)
                                <span class="text_red">等待认证</span>
                            @elseif($item->status ==1)
                                <span class="text_green">认证通过</span>
                            @elseif($item->status ==-1)
                                <span class="text_orange">认证失败</span>
                            @endif
                        </td>
                        <td>
                            <a href="javascript:;" onclick="del({{$item->id}})">删除</a>
                        </td>

                    </tr>
                @empty
                    <tr>
                        <td colspan="6" style="color: #999; text-align: center;">没有数据</td>
                    </tr>
                @endforelse
                </tbody>
            </table>
        </div>
        <div style="margin: 20px 20px;display: flex; justify-content: center">
            <div>
                {{ $data->appends(['queryValue' => $queryValue,'queryType'=>$queryType])->links() }}
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script>
        $(function () {
            var link = $("#account-certification");
            link.parent().parent().parent().addClass("active");
            link.parent().addClass("active");

            $("#search_text").val('{{$queryValue}}');
        });

        //	删除确认
        function del(id) {
            layer.confirm("确定删除吗？", {
                title: "提示",
                btn: ["确定", "取消"]
            }, function () {
                $.ajax({
                    type: "post",
                    url: '/account/auth/personal/del?id=' + id,
                    dataType: "json",
                    data: {_token: '{{csrf_token()}}'},
                    success: function (data) {
                        if (data.code === 200) {
                            layer.msg("删除成功", {
                                icon: 1,
                                time: 1000
                            }, function () {
                                window.location.reload();
                            });
                        } else {
                            layer.msg(data.msg);
                        }
                    }
                })
            });
        }
    </script>

@endsection
